package com.ttbj.rule.service.impl;

import com.ttbj.product.bean.dto.CargoDto;
import com.ttbj.rule.po.CarriageRule;
import com.ttbj.rule.service.BillStrategy;

/**
 * 体积计费
 * @author Medivh
 * @date 2018年6月7日 上午10:24:06
 */
public class BillBulkStrategy implements BillStrategy {
 
	@Override
	public Float strategyInterface(Float distance,CargoDto cargo, CarriageRule bill) {
		Float cargoHeight = cargo.getCargoHeight();//高
		Float cargoLong = cargo.getCargoLong();//长
		Float cargoWide = cargo.getCargoWide();//宽
		/*体积*/
		Float volume = (cargoHeight == null && cargoLong == null && cargoWide == null  )? 1f: cargoHeight * cargoLong * cargoWide;
		volume = volume <= 0.01f ? 0.01f : volume;
		System.out.println("体积是："+volume);
		Integer cargoAmount = cargo.getCargoAmount();
		cargoAmount = cargoAmount == null || cargoAmount <= 0  ? 1 : cargoAmount;
		Float billBulkPrice = bill.getBillBulkPrice();
		return billBulkPrice == null ? 0 : billBulkPrice*volume;
	}

}
